<template>
	<div id="my_note">
		<div class="nav">
			<ul class="am-avg-sm-2">
				<li><a  @click="uni.redirectTo({
					url:'my_note'
				})">已发表</a></li>
				<li><a class="cur" @click="uni.redirectTo({
					url:''
				})">草稿箱</a></li>
			</ul>
		</div>
		<div class="cont">
			<div id="app">
				<ul v-for="b in articles">
					<li>
						<div class="box_cont" @click="itemClicked(b)">
							<a title=""  @click="uni.navigateTo({
								url:'../main/beautiful_detail='
							})">
								<div class="pic">
									<img :src="'https://yo.docshare.org.cn'+b.background">
								</div>
								<div class="project_cont">
									<p>{{b.articletitle}}</p>
								</div>
								<div class="clear"></div>
							</a>
						</div>
						<span class="date">{{b.articletime}}</span>
						
						<!-- <input type="submit" style="width: 30px; height: 17px; alien:right; font-size: 5px;" @click="delete1(b)" value="发布" /> -->
						<div class="button" style="display: flex;">
							<!-- <input type="submit" class="gray_hollow" @click="delete1(b)" value="发布" /> -->
						<button   @click="delete1(b)">删除</button>
							<button   @click="release(b)">发布</button>
						</div>
					</li>
				</ul>
				<div id="none">
					没有更多了
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import config from '@/config'
	export default {
		data() {
			return {
				uni,
				config,
				aid: '',
				articles: [],
				id: '',
			}
		},
		methods: {
			itemClicked: function(item) {
				this.id = item.id;
			},
			deletebox: function(item) {
				this.id = item.id;
				uni.request({
					url: `${config.baseUrl}/article/deletebox?token=` + uni.getStorageSync('token'),
					data:{
						id:this.id,
					},
					method: 'POST',
					success(r) {
						if (r.data.succ) {
							uni.navigateTo({
								url:'box'
							})
						} else {}
					},
					complete(res){
						if(res.data && res.data.msg){
							uni.showToast({
								icon:'none',
								title:res.data.msg
							})
						}
					},
				});
			},
			release: function(item) {
				this.id = item.id;
				uni.request({
					url: `${config.baseUrl}/article/releasebox?token=` + uni.getStorageSync('token'),
					data:{
						id:this.id,
					},
					method: 'POST',
					success(r) {
						if (r.data.succ) {
							uni.navigateTo({
								url:'box'
							})
						} else {}
					},
					complete(res){
						if(res.data && res.data.msg){
							uni.showToast({
								icon:'none',
								title:res.data.msg
							})
						}
					},
				});
			},
		},
		onLoad() {
			var that = this;
			uni.request({
				url: `${config.baseUrl}/article/box?token=${uni.getStorageSync('token')}`,
				method: "GET",
				success(r) {
					if (r.data.succ) {
						that.articles = r.data.data;
					} else {
			
					}
				},
					complete(res){
						if(res.data && res.data.msg){
							uni.showToast({
								icon:'none',
								title:res.data.msg
							})
						}
					},
			})
		}
	}
</script>

<style>
</style>
